<?php
require 'settings.php';
require 'db.php';
?>

<html>
<head>
<title><?php echo $corp_name?> Industry Manager - Corporate material prices</title>

<style type="text/css">
table, th, td
{
border: 1px solid black;
border-collapse: collapse;
}
</style>

</head>
<body>
<h1 class=c_page_title>Corportate material prices</h1>

<?php
$table_name = "prices_materials";
$get_table_mod_timestamp->bind_param( 's', $table_name );
$get_table_mod_timestamp->bind_result( $last_update );
$get_table_mod_timestamp->execute();
$get_table_mod_timestamp->fetch();
echo 'Prices last updated on <font style="font-weight:bold">'.$last_update.'</font><br />';
$get_table_mod_timestamp->close();
?>

<form id="corporate_prices_edit" action="update_current_prices.php" method="post">
<table id="material_prices">
<tr><td>Name</td><td>Current price</td><td>New price</td></tr>
	<?php
		//we need to generate input fields for all prices
		$show_corp_prices->bind_result( $mat_name, $mat_id, $mat_price, $mat_volume );
		$show_corp_prices->execute();
		while( $show_corp_prices->fetch() )
		{
				echo '<tr><td>'.$mat_name.'</td><td>'.number_format($mat_price, 2, '.', '').'</td><td><input name="'.$mat_id.'" type="text" value="'.number_format($mat_price, 2, '.', '').'"/></td></tr>';
		}
		$show_corp_prices->close();
	?>
</table>
<input type="submit" value="Update prices" />
</form>


<a href="index.php">Back to main screen</a>
</body>
</html>